import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import 'router/RouteConfig.dart';
import 'util/Logger.dart';
import 'util/TranslationHelper.dart';

void main() async{
  await ScreenUtil.ensureScreenSize();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    //填入设计稿中设备的屏幕尺寸,单位dp
    ScreenUtil.init(context, designSize: const Size(360, 690), minTextAdapt: true, splitScreenMode: true);
    return GetMaterialApp(
      debugShowCheckedModeBanner: false,
      enableLog: true,
      logWriterCallback: Logger.write,
      initialRoute: RouteConfig.login,
      getPages: RouteConfig.pages,
      locale: TranslationHelper.locale,
      fallbackLocale: TranslationHelper.fallbackLocale,
      translations: TranslationHelper(),
      builder: (ctx, widget){
        return MediaQuery(
          ///设置文字大小不随系统设置改变
            data: MediaQuery.of(context).copyWith(
                textScaler: const TextScaler.linear(1.0)
            ),
            child: widget??const SizedBox.shrink()
        );
      },
    );
  }
}

